{% extends 'users/management/base.html' %}

{% block title %}
	部门管理
{% endblock %}

{% block management-external %}
	{% load static %}
	<link rel="stylesheet" type="text/css" href="{% static 'css/users/management/department.css' %}"/>
{% endblock %}

{% block management-main %}
	<div class="row">
		{% if user.department_set.count != 0 %}
			<h3 class="text-center text-info">{{ user.username }}创建的部门</h3>
			<hr/>
			<div class="col-sm-12">
				{% for department in user.department_set.all %}
					<div class="users-management-department-box">
						<div class="users-management-department-box-header">
							<a href="{% url 'departments:department_info' department.id %}" target="_blank"><h4>{{ department.name }}</h4></a>
						</div>
						<div class="users-management-deparment-box-body">
							<span class="glyphicon glyphicon-calendar"></span><span>{{ department.created_time }}</span>
							<p>{{ department.desc }}</p>
						</div>
						<div class="users-management-deparment-box-footer">
							<a href="{% url 'departments:update_department' department.id %}" target="_blank"><button type="button" class="btn btn-sm btn-default">修改</button></a>
							<button type="button" class="btn btn-sm btn-danger" data-toggle="modal" data-target="#myModal">解散</button>
						</div>
					</div>
					<!--模态框-->
					<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
					    <div class="modal-dialog">
					        <div class="modal-content">
					            <div class="modal-header">
					                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					                <h4 class="modal-title" id="myModalLabel">确定要解散该部门吗？</h4>
					            </div>
					            <div class="modal-body">您即将要解散{{ department.name }}，点击确定以解散。</div>
					            <div class="modal-footer">
					                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					                <form action="{% url 'departments:delete_department' department.id %}" method="post" style="display: inline;">
					                	{% csrf_token %}
					                	<button type="sumbit" class="btn btn-primary">确定</button>
					            	</form>
					            </div>
					        </div><!-- /.modal-content -->
					    </div><!-- /.modal -->
					</div>
				{% endfor %}
			</div>
		{% else %}
			<div class="col-sm-12">
				<div class="alert alert-warning">该用户还没有创建过部门</div>
			</div>
		{% endif %}
	</div>
{% endblock %}